import request from "@/utils/request";
import {AccessoryQuery, AccessoryForm} from "./types";
import { AxiosPromise } from "axios";

/**
 * 科目分页数据
 *
 * @param queryParams
 */
export function getAccessoryPage(
	queryParams: AccessoryQuery
): AxiosPromise<PageResult<[]>> {
	return request({
		url: '/api/v1/accessory/page',
		method: 'get',
		params: queryParams
	});
}

/**
 * 获取店铺表单数据
 *
 * @param queryParams
 */
export function getAccessoryForm(id: number): AxiosPromise<AccessoryForm> {
	return request({
		url: '/api/v1/accessory/' + id + '/form',
		method: 'get'
	});
}

/**
 * 保存科目
 *
 * @param data
 */
export function saveAccessory(data: AccessoryForm) {
  return request({
    url: "/api/v1/accessory",
    method: "post",
    data: data,
  });
}

/**
 * 删除科目
 *
 * @param ids
 */
export function deleteAccessory(ids: string) {
	return request({
		url: '/api/v1/accessory/' + ids,
		method: 'delete'
	});
}

/**
 * 通过末级科目查找辅助项
 *
 * @param queryParams
 */
export function findAll(): AxiosPromise<[]> {
	return request({
		url: '/api/v1/accessory/findAll',
		method: 'get'
	});
}
